public class ThreadDemo12join {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
            for (int i = 0; i < 3000; i++) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t线程结束");
        });
        t.start();
        t.join(3000,500);//第一个参数是毫秒，第二个参数是纳秒
        System.out.println("main线程结束");
    }
}
